package com.xjm.i1.constant;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import org.apache.poi.ss.usermodel.IndexedColors;

@Getter
public enum ColorEnum {

    CYAN("青色", IndexedColors.SKY_BLUE), MAGENTA("品红", IndexedColors.PINK1), YELLOW("黄色", IndexedColors.YELLOW1),
    BLACK("黑色", IndexedColors.GREY_80_PERCENT), RED("红色", IndexedColors.RED1), GREEN("绿色", IndexedColors.SEA_GREEN),
    BULE("蓝色", IndexedColors.ROYAL_BLUE), GRAY("灰色", IndexedColors.GREY_25_PERCENT);

    private String val;
    private IndexedColors indexedColor;

    ColorEnum(String val, IndexedColors indexedColor) {
        this.val = val;
        this.indexedColor = indexedColor;
    }

    public static ColorEnum[] getMinColorEnumOrdered() {
        return new ColorEnum[]{ColorEnum.BLACK, ColorEnum.CYAN, ColorEnum.MAGENTA, ColorEnum.YELLOW, ColorEnum.RED, ColorEnum.GREEN, ColorEnum.BULE};
    }

    public static ColorEnum[] getMaxColorEnumOrdered() {
        return new ColorEnum[]{ColorEnum.GRAY, ColorEnum.BLACK,
                ColorEnum.YELLOW, ColorEnum.MAGENTA, ColorEnum.CYAN };
    }

    public static String[] getContrastStringOrdered() {
        return new String[]{ColorEnum.CYAN.val, ColorEnum.MAGENTA.val,
                ColorEnum.YELLOW.val, ColorEnum.BLACK.val, ColorEnum.GRAY.val};
    }

    public static String[] getDensityStringOrdered() {
        return new String[]{ColorEnum.CYAN.val, ColorEnum.MAGENTA.val, ColorEnum.YELLOW.val, ColorEnum.BLACK.val,
                ColorEnum.RED.val, ColorEnum.GREEN.val, ColorEnum.BULE.val};
    }

    public static ColorEnum getColorEnumByVal(String val) {
        if (StrUtil.isEmpty(val)) {
            return null;
        }
        for (ColorEnum colorEnum : ColorEnum.values()) {
            if (colorEnum.getVal().equals(val)) {
                return colorEnum;
            }
        }
        return null;
    }
}
